<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>扫码加入城市群</title>
{$h->import('static/css/layui.css')}
{$h->import('static/css/HyqPublic.css')}
{$h->import('static/css/StoreCode.css')}

</head>
<style type="text/css">
  /*------------分页部分--------------*/
    .pageing-container-h{
      display: flex;
      justify-content: space-between;
      padding: 0px 20px 20px 20px;
    }
    .pageing-content-h{
      line-height: 28px;
    }
    .pageing-content-h a{
      border: 1px solid #e2e2e2;
      padding: 4px 15px;
      color: #333;
      line-height: 28px;
      border-radius: 2px;
    }
   .current{
     background: #1E9FFF !important;
     color: #fff !important;
   }
</style>
<body>
<!-- 顶部导航 start -->
<div class="StoreCode_headerNav_container">
	<ul class="StoreCode_headerNav_content">
		<li>
			<a href="/Addons/StoresCode/admin/StoresCode/index.html" >扫码添加店主</a>
		</li>
		<li>
			<a href="/Addons/StoresCode/admin/GroupCode/index.html">扫码加入门店群</a>
		</li>
		<li>
			<a href="index.html" class="StoreCode_headerNavActive">扫码加入城市群</a>
		</li>
	</ul>
</div>
<!-- 顶部导航 end -->
<!-- 主要内容区 -->
<div class="StoreCode_main_container">
	<!-- 主要内容区切换tabs -->
	<ul class="StoreCode_mainNav_container">
		<a href="index.html"><li data-type="store">门店列表</li></a>
		<a href="city_data_stores-1.html"><li class="StoreCode_mainNavActive" data-type="data">数据分析</li></a>
	</ul>
	<!-- 切换区数据分析页面 -->
	<div class="StoreCode_TabsDataAnalysis_container" >
		<div class="StoreCode_TabsDataAnalysis_Header_container">
			<h3>数据总览	<span style="font-size: 10px;">统计说明</span><i class="layui-icon layui-icon-help" style="font-size: 8px;margin-left: 10px;cursor: pointer;" id="sone" onmouseout="mous()" onmouseover="check()"></i></h3>
			<div class="StoreCode_TabsDataAnalysis_Header_content">
				<ul class="StoreCode_TabsDataAnalysis_HeaderList_container">
					<li>
						<b>{$data_count["new_count"]}</b>
						<span>今日点击次数</span>
					</li>
					<li>
						<b>{$data_count["add_count"]}</b>
						<span>今日添加客户数</span>
					</li>
					<li>
						<b>{$data_count["del_count"]}</b>
						<span>今日流失客户数</span>
					</li>
				</ul>
				<ul class="StoreCode_TabsDataAnalysis_HeaderList_container">
					<li>
						<b>{$data_count["new_counts"]}</b>
						<span>总点击次数</span>
					</li>
					<li>
						<b>{$data_count["add_counts"]}</b>
						<span>总添加客户数</span>
					</li>
					<li>
						<b>{$data_count["del_counts"]}</b>
						<span>总流失客户数</span>
					</li>
				</ul>
			</div>
		</div>
		<div class="gray-bar"></div>
		<!-- 第二级切换 -->
		<ul class="StoreCode_TabsDataAnalysis_secendTabs_container">
			<li {if $type == 1} class="StoreCode_TabsDataAnalysis_secendTabs_active" {/if} ><a href="city_data_stores-1.html">查看客户数据</a></li>
			<li {if $type == 2} class="StoreCode_TabsDataAnalysis_secendTabs_active" {/if}><a href="city_data_stores-2.html">查看城市数据</a></li>
		</ul>
		<!-- 查看客户数据 tabs区域 -->
		<div class="StoreCode_TabsDataAnalysis_Main_container" {if $type == 2} style="display: none;" {/if}>
			<div class="StoreCode_TabsStoreList_From_container layui-form">
				<div class="public_form_conainer public_search_container">
					<span class="public_formTitle">客户昵称：</span>
					<div class="public_search_content">
						<input type="text" placeholder="请输入客户昵称" id="name" value="{$name}">
						<svg t="1622189504456" class="icon" onclick="search('name')" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2625" width="17" height="17"><path d="M426.666311 853.332622a426.666311 426.666311 0 1 1 426.666311-426.666311 426.666311 426.666311 0 0 1-426.666311 426.666311z m0-767.99936a341.333049 341.333049 0 1 0 341.333049 341.333049 341.333049 341.333049 0 0 0-341.333049-341.333049z" p-id="2626" fill="#8c8c8c"></path><path d="M981.332516 1023.999147a42.666631 42.666631 0 0 1-30.293309-12.373323L682.666098 743.252714A42.666631 42.666631 0 0 1 743.252714 682.666098l268.37311 267.946443a42.666631 42.666631 0 0 1 0 60.586616 42.666631 42.666631 0 0 1-30.293308 12.79999z" p-id="2627" fill="#8c8c8c"></path></svg>
					</div>
				</div>
				
				<div class="public_form_conainer public_select_container">
					<span class="public_formTitle">城市负责人：</span>
					<div class="public_select_content">
						<select id="user" lay-verify="required" lay-filter="lay-search">
							<option value=""></option>
							{loop $user_list as $users}
								<option value="{$users['id']}" {if $user == $users['id']} selected {/if}>{$users["name"]}</option>
							{/loop}
						</select>
					</div>
				</div>
				<div class="public_form_conainer public_select_container">
					<span class="public_formTitle">城市：</span>
					<div class="public_select_content">
						<select id="stores_city" lay-verify="required" lay-filter="lay-search">
							<option value=""></option>
							{loop $citys as $city}
								<option value="{$city}" {if $city == $stores_city} selected {/if}>{$city}</option>
							{/loop}
						</select>
					</div>
				</div>
				<div class="public_form_conainer public_laydate_container">
					<span class="public_formTitle">时间筛选：</span>
					<div class="public_laydate_content">
						<input type="text" class="layui-input" id="times" value="{$times}" placeholder="请选择日期范围">
						<svg style="width:12px" t="1622189504456" class="icon" onclick="search('times')" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2625" width="17" height="17"><path d="M426.666311 853.332622a426.666311 426.666311 0 1 1 426.666311-426.666311 426.666311 426.666311 0 0 1-426.666311 426.666311z m0-767.99936a341.333049 341.333049 0 1 0 341.333049 341.333049 341.333049 341.333049 0 0 0-341.333049-341.333049z" p-id="2626" fill="#8c8c8c"></path><path d="M981.332516 1023.999147a42.666631 42.666631 0 0 1-30.293309-12.373323L682.666098 743.252714A42.666631 42.666631 0 0 1 743.252714 682.666098l268.37311 267.946443a42.666631 42.666631 0 0 1 0 60.586616 42.666631 42.666631 0 0 1-30.293308 12.79999z" p-id="2627" fill="#8c8c8c"></path></svg>
					</div>
				</div>
				<div class="public_form_conainer public_select_container">
					<span class="public_formTitle">流失状态：</span>
					<div class="public_select_content ">
						<select id="status" lay-verify="required" lay-filter="lay-search">
							<option value=""></option>
							<option value="1" {if $status == 1} selected {/if}>未流失</option>
							<option value="2" {if $status == 2} selected {/if}>已流失</option>
						</select>
					</div>
				</div>
				<div class="public_form_conainer public_select_container">
					<span class="public_formTitle">用户位置：</span>
					<div class="public_select_content ">
						<select id="user_city_one" lay-verify="required" lay-filter="lay-search">
							<option value=""></option>
							{loop $user_city as $user_citys}
								<option value="{$user_citys}" {if $user_city_one == $user_citys} selected {/if}>{$user_citys}</option>
							{/if}
						</select>
					</div>
				</div>
				<button class="layui-btn layui-btn-primary StoreCode_TabsStoreList_From_button public_button" onclick="reset()">重置</button>
			</div>
			<!-- table 上的按钮区域 -->
			<div class="StoreCode_TabsStoreList_tableHeader_container">
				<h3>共{count($data)}个客户</h3>
				<ul class="StoreCode_TabsStoreList_tableHeaderButton_container">
					<li>
						<button type="button" class="layui-btn layui-btn-primary public-button-border-blue public_button" onclick="tags()">批量打标签</button>
					</li>
				</ul>
			</div>
			<!-- table 区域 -->
			<div class="StoreCode_TabsStoreList_table_container mcheckbox-table">
				<table class="layui-table layui-form" lay-skin="line">
					<thead>
					    <tr>
							<th lay-data=""><input type="checkbox" name="ched" lay-skin="primary" value="all" lay-filter="alls"></th>
				      		<th lay-data="">客户昵称</th>
							<th lay-data="">城市负责人</th>
							<th lay-data="">标签</th>
							<th lay-data="">城市</th>
							<th lay-data="">用户位置</th>
							<th lay-data="">添加时间</th>
							<th lay-data="">流失状态</th>
							<th lay-data="">操作</th>
					    </tr>
				  	</thead>
				  	<tbody>
					  	{loop $data as $datas}
						<tr>
							<td id="check" class="check_{$datas['id']}" {if $datas['p_status'] !=1} onmouseout="mous({$datas['id']})" onmouseover="checks({$datas['id']})" {/if}>
								<input type="checkbox" name="ched" lay-skin="primary" value="{$datas['user_id']}___{$datas['external_userid']}" {if $datas['p_status'] !=1}  disabled="true" {/if}>
							</td>
						    <td>{$datas["name"]}</td>
				      		<td>{$datas["user"]["name"]}</td>
				      		<td style="width: 300px;">
					      		{if count($datas["tags"]) >= 1}
					      		{loop $datas["tags"] as $tags}
						        	<span class="table-public-label">{$etTagArr[$tags]}</span>
					      		{/loop}{else}----{/if}
						    </td>
						    <td>{$datas["stores_city"]}</td>
						    <td>{$datas["external_address"]}</td>
						    <td>{$datas["ctime"]}</td>
						    <td>{if $datas["p_status"] == 1}正常{else}已流失{/if}</td>
						    <td>
						      	<a href="/Addons/StoresCode/admin/Data/index-{$datas['user_id']}.html" class="table-public-btn">员工详情</a>
					      	</td>
						</tr>
						{/loop}
				  	</tbody>
				</table>
			</div>
			<div class="main-container-h pageing-container-h">
	        <div class="pageing-content-h">
	            <span>{$p->totalnum}条/{$p->totalpage}页</span>
	        </div>
          	<ul class="pageing-content-h">{P weidogsadmin}</ul>
         	</div>
		</div>
		<!-- 查看门店数据 -->
		<div class="StoreCode_TabsDataStore_Main_container" {if $type == 1} style="display: none;" {/if}>
			<div class="StoreCode_TabsStoreList_From_container layui-form">
				<div class="public_form_conainer public_select_container">
					<span class="public_formTitle">城市：</span>
					<div class="public_select_content">
						<select id="stores_citys" lay-verify="required" lay-filter="lays-search">
							<option value=""></option>
							{loop $citys as $city}
								<option value="{$city}" {if $city == $stores_citys} selected {/if}>{$city}</option>
							{/loop}
						</select>
					</div>
				</div>
				
				<div class="public_form_conainer public_select_container">
					<span class="public_formTitle">开启状态：</span>
					<div class="public_select_content ">
						<select id="statuss" lay-verify="required" lay-filter="lays-search">
							<option value=""></option>
							<option value="1" {if $statuss == 1} selected {/if}>已开启</option>
							<option value="2" {if $statuss == 2} selected {/if}>未开启</option>
							<option value="3" {if $statuss == 3} selected {/if}>已删除</option>
						</select>
					</div>
				</div>

				<button class="layui-btn layui-btn-primary StoreCode_TabsStoreList_From_button public_button" onclick="reset()">重置</button>
			</div>
			<!-- table 上的按钮区域 -->
			<div class="StoreCode_TabsStoreList_tableHeader_container">
				<h3>共{count($stores_list)}个城市</h3>
			</div>
			<!-- table 区域 -->
			<div class="StoreCode_TabsStoreList_table_container">
				<table class="layui-table layui-form" lay-skin="line">
					<colgroup>
						<col>
						<col>
						<col>
						<col>
					</colgroup>
					<thead>
						<tr style="background: #fcfcfc;">
							<th>城市</th>
							<th>今日添加客户数</th>
							<th>添加客户总数</th>
							<th>门店状态</th>
						</tr> 
					</thead>
					<tbody>
						{loop $stores_list as $stores}
						<tr>
							<td>{$stores["stores_city"]}</td>
							<td>{$stores["add_count"]}</td>
							<td>{$stores["add_counts"]}</td>
							<td>{$stores["text"]}</td>
						</tr>
						{/loop}
					</tbody>
				</table>
			</div>
			<div class="main-container-h pageing-container-h">
	        <div class="pageing-content-h">
	            <span>{$p->totalnum}条/{$p->totalpage}页</span>
	        </div>
          	<ul class="pageing-content-h">{P weidogsadmin}</ul>
         	</div>
		</div>
	</div>
	<div class="layui-form" id="updateDiv" style="display: none;padding: 30px;" >
		<div class="clue-add-tag-div">
			<h2 class="" style="text-align: center; font-size: 20px; font-weight: bold; padding-bottom: 20px;"> 批量打标签 </h2>
			<div class="layui-form-item">
				<lable class="layui-form-label">选择标签:</lable>
				<div class="layui-input-block select-tag" style="">
					<input type="hidden" id="data_s" value="">
					<input type="hidden" name="addTag" id="addTag" value="">
					<input type="text" value="" id="checkLable" readonly placeholder="请选择标签" autocomplete="off" class="layui-input">
				</div>
			</div>
		</div>
		<div class="layui-form-item">
      		<div class="pushSOP_button_content">
        		<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" onclick="add_tag()" style="float: right;">添加</button>
      		</div>
        </div>
	</div>	
</div>
<script src="/cdn/jquery.min.js"></script>
	<script src="/layui/layui.all.js"></script>
	<script src="/js/ajax.js"></script>
<script type="text/javascript">
	var form = layui.form;
	function check(){
		layer.tips('<a>1、点击次数：点击进入区域扫码页面的次数<br>2、添加客户数：点击添加的客户总数，若客户重复添加将会重复计数<br>3、流失客户数：点击添加后将成员删除的客户数</a>', '#sone', {
			tips: [3, 'white'],
			area: ['450px', 'auto'],
	    	time: 50000
		});
	}

	function checks(id){
		layer.tips('<a>客户流失状态，不可选择</a>', '.check_'+id, {
		  	tips: [1, 'white'],
			area: ['200px', 'auto'],
    		time: 50000
		});
	}

	function mous(id){
		layer.closeAll();
	}

	//全选/全不选
	form.on('checkbox(alls)', function(data){
		var checkbox = $("#check input[type='checkbox']");
		checkbox.each(function (index, item) {
			if(!item.disabled){
				item.checked = data.elem.checked;
			}
		});
		form.render('checkbox');
	})
	//批量打标签
	function tags(){
		var arr_box = Array();
		$("#check input[type='checkbox']").each(function() {
			if($(this)[0].checked){
				arr_box.push($(this).val());
			}
	    });
		if(arr_box.length < 1){
			layer.msg("请选择客户");
			return false;
		}
		$("#updateDiv").show();
	    $("#data_s").val(arr_box.toString());
	    layer.open({
	        title: [' ', 'font-weight:bold;'],
	        type: 1,
	        area: ['700px', 'auto'],
	        shadeClose: true,
	        content: $('#updateDiv'),
	        end : function() {
				$("#updateDiv").hide();
			}
	    })
	}

	//选择标签
	$('#checkLable').on('click',function(){
		layer.open({
			type: 2,
			title: '请选择标签',
			shadeClose: true,
			shade: 0.2,
			area: ['700px', '530px'],
			content: 'select_tag.html'
		}); 
    })

    //提交标签
    function add_tag(){
		var ids = $("#data_s").val();
		var tags = $("#addTag").val();
		if(!addTag){
			layer.msg('请先选择标签', function(){});
	    	return false;
		}
		myAjaxPost(false, true, 'add_tges.html', { ids:ids,tags:tags}, function (resp) {
			layer.msg(resp.msg);
			if(resp.status == "success"){
				setTimeout(function(){
					location.reload();
	            },1000);
			}
		})
	}

	//搜索
	function search(){
		var stores_city = $("#stores_city").val();
		var name = $("#name").val();
		var user = $("#user").val();
		var status = $("#status").val();
		var user_city_one = $("#user_city_one").val();
		var times = $("#times").val();
		if(stores_city == "{$stores_city}" && name == "{$name}" && user == "{$user}" && status == "{$status}" && user_city_one == "{$user_city_one}" && times == "{$times}"){
			return false;
		}
		window.location.href = window.location.pathname+"?stores_city="+stores_city+"&user="+user+"&user_city_one="+user_city_one+"&times="+times+"&status="+status+"&name="+name;
	}
	
	//搜索
	form.on("select(lay-search)", function(data){
		var stores_city = $("#stores_city").val();
		var name = $("#name").val();
		var user = $("#user").val();
		var status = $("#status").val();
		var user_city_one = $("#user_city_one").val();
		var times = $("#times").val();
		if(stores_city == "{$stores_city}" && name == "{$name}" && user == "{$user}" && status == "{$status}" && user_city_one == "{$user_city_one}" && times == "{$times}"){
			return false;
		}
		window.location.href = window.location.pathname+"?stores_city="+stores_city+"&user="+user+"&user_city_one="+user_city_one+"&times="+times+"&status="+status+"&name="+name;
	})

	form.on("select(lays-search)", function(data){
		var stores_citys = $("#stores_citys").val();
		var statuss = $("#statuss").val();
		if(stores_citys == "{$stores_citys}" && statuss == "{$statuss}"){
			return false;
		}
		window.location.href = window.location.pathname+"?stores_citys="+stores_citys+"&statuss="+statuss;
	})

    //重置
	function reset(){
		window.location.href = window.location.pathname;
	}
</script>
<script type="text/javascript">
	layui.use('form', function(){
		var form = layui.form;

	  //监听提交
	  form.on('submit(formDemo)', function(data){
	  	layer.msg(JSON.stringify(data.field));
	  	return false;
	  });
	  
	});
	layui.use('laydate', function(){
	  var laydate = layui.laydate;
	  //日期时间范围
	  laydate.render({ 
	    elem: '#times'
	    ,range: true //或 range: '~' 来自定义分割字符
	  });
	  
	});
	layui.use('table', function(){
	  var table = layui.table;
	  //转换静态表格
	  table.init('clientTable', {
	    page: !{limit: 1},
	    // 页码变化会触发
	    done: function(res, curr, count) {
	      currTablePage = curr
	    }
	  })
	  table.on('checkbox(clientTable)', function(obj){
	    var result = getPageSelected();
	    tableSelected[currTablePage] = result
	  })
	})
</script>
</body>
</html>